home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / FALCON / ACC / OUTLINE.ACC / GEMSKEL.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  4.7 KB  |  228 lines

  1. /* ================================================================
  2.  * FILE: GEMSKEL.C
  3.  * ================================================================
  4.  * DATE: November 20, 1992
  5.  * DESCRIPTION: GEM Application Skeleton
  6.  */
  7.  
  8.  
  9. /* INCLUDES 
  10.  * ================================================================
  11.  */
  12. #include <sys\gemskel.h>
  13. #include <stdlib.h>
  14. #include <tos.h>
  15.  
  16. #include "country.h"
  17. #include "text.h"
  18.  
  19. /* DEFINES
  20.  * ================================================================
  21.  */
  22. #define AP_TERM        50    /* NEW AES Call! */
  23.  
  24.  
  25.  
  26. /* EXTERNS
  27.  * ================================================================
  28.  */
  29. int open_vwork( void );    /* From FSM.C */
  30. void close_vwork( void );
  31.  
  32.  
  33.  
  34. /* GLOBALS
  35.  * ================================================================
  36.  */
  37.  
  38. /* VDI arrays */
  39. int    contrl[12], intin[128], intout[128], ptsin[128], ptsout[128],
  40.     work_in[12], work_out[57];
  41. int    phys_handle, vhandle, xres, yres;
  42.  
  43.  
  44. /* AES variables */
  45. int    AES_Version; 
  46. int     gl_ncolors;
  47. int    gl_apid, gl_hchar, gl_wchar, gl_hbox, gl_wbox;
  48. GRECT    desk;
  49. OBJECT    *menu;
  50.  
  51.  
  52. /* null structures */
  53. GRECT    grect0 = { 0, 0, 0, 0 };
  54. MOBLK    moblk0 = { 0, 0, 0, 0, 0 };
  55. MFDB    mfdb0 = { NULL, 0, 0, 0, 0, 0, 0, 0, 0 };
  56.  
  57.  
  58. /* Locals used for evnt_multi input, can be set via set_events()
  59.  * ================================================================
  60.  */
  61. static    int    ev_mask=0, ev_clicks=0, ev_bmask=0, ev_bstate=0;
  62. static    MOBLK    ev_m1 = { 0, 0, 0, 0, 0 };
  63. static    MOBLK    ev_m2 = { 0, 0, 0, 0, 0 };
  64. static    long    ev_time=0L;
  65.  
  66.  
  67. /* FUNCTIONS
  68.  * ================================================================
  69.  */
  70.  
  71.  
  72. /*
  73.  * main()
  74.  * ================================================================
  75.  */
  76. void
  77. main( void )
  78. {
  79.     int    event, msg[8], key, nclicks;
  80.     MRETS    mrets;
  81.  
  82.  
  83. /*
  84.  * See if we were run from the AUTO folder...
  85.  */
  86.         gl_apid = appl_init();
  87.  
  88.     /* Get the AES version #.  TOS 3.0 is TT TOS */
  89.     AES_Version = _GemParBlk.global[0];
  90. /*
  91.  * Set up work_in to initialize VDI functions to useful values,
  92.  * Get the physical workstation handle from the AES, then
  93.  * open a virtual workstation and get our AES work area's extent.
  94.  */
  95.     phys_handle = graf_handle(&gl_wchar,&gl_hchar,&gl_wbox,&gl_hbox );
  96.  
  97.     Wind_get( 0, WF_WORKXYWH, ( WARGS *)&desk );
  98.     
  99.     /* Call initialization hooks */
  100.     rsrc_init();
  101.  
  102.  
  103.     if( !open_vwork() )
  104.         {
  105.        /* Unable to open workstation - exit application */
  106.            form_alert( 1, alert18 );
  107.        gem_exit( 0 );
  108.         }
  109.     close_vwork();
  110.     gl_ncolors = work_out[13];
  111.     xres       = work_out[0];
  112.     yres       = work_out[1];
  113.     vhandle = 0;
  114.  
  115.     
  116.     wind_init();
  117.     evnt_init();
  118.     
  119.     /* Main event loop */
  120.     do
  121.     {
  122.  
  123.         event = Evnt_multi( ev_mask, ev_clicks, ev_bmask, ev_bstate,
  124.                     &ev_m1, &ev_m2, ( WORD *)msg, ev_time,
  125.                     &mrets,(WORD *)&key,(WORD *)&nclicks );
  126.         wind_update( BEG_UPDATE );
  127.         
  128.  
  129.     /* Dispatch events.
  130.      * It is possible to get more than one event at a time, so if the
  131.      * order of event handling is important to you, change the order
  132.      * in which they're handled here.
  133.      */
  134.         if( event & MU_MESAG )
  135.             switch( msg[0] ) {
  136.  
  137.                 case MN_SELECTED:
  138.                 break;
  139.  
  140.                 case WM_REDRAW:
  141.                 case WM_TOPPED:
  142.                 case WM_CLOSED:
  143.                 case WM_FULLED:
  144.                 case WM_ARROWED:
  145.                 case WM_HSLID:
  146.                 case WM_VSLID:
  147.                 case WM_SIZED:
  148.                 case WM_MOVED:
  149.                 case WM_NEWTOP:
  150.                     do_windows( msg, &event );
  151.                 break;
  152.  
  153.                 case AC_OPEN:
  154.                     acc_open( msg );
  155.                 break;
  156.                 
  157.                 case AP_TERM:
  158.                 case AC_CLOSE:
  159.                     acc_close( msg );
  160.                 break;
  161.  
  162.                 default:
  163.                     break;
  164.             } /* switch */
  165.         /* MU_MESAG */
  166.  
  167.         wind_update( END_UPDATE );
  168.  
  169.     /*
  170.      * Event handling routines zero out the event variable
  171.      * to exit the application.
  172.      */
  173.     } while( event );
  174.  
  175.     gem_exit( 0 );
  176. }
  177.  
  178.  
  179. /* gem_exit()
  180.  * ================================================================
  181.  * Clean exit.
  182.  */
  183. void
  184. gem_exit( int code )
  185. {
  186.     int ignore[8];
  187.  
  188. /*
  189.  * Go into an endless loop if we're a desk accessory...
  190.  */
  191.     if( !_app ) for(;;) evnt_mesag( ignore );
  192.  
  193. /*
  194.  * Otherwise, clean up and call the exit hooks
  195.  */
  196.     wind_update( END_UPDATE );
  197.     close_vwork();
  198.     wind_exit();   
  199.     appl_exit();
  200.     exit( code );
  201. }
  202.  
  203.  
  204. /*
  205.  * evnt_set()
  206.  * ================================================================
  207.  * Set parameters for main evnt_multi.
  208.  */
  209. void
  210. evnt_set( int mask, int clicks, int bmask, int bstate,
  211.       MOBLK *m1, MOBLK *m2, long time )
  212. {
  213.     if( !mask ) gem_exit( -1 );
  214.  
  215.     if( mask != -1 )    ev_mask = mask;
  216.     if( clicks != -1 )    ev_clicks = clicks;
  217.     if( bmask != -1 )    ev_bmask = bmask;
  218.     if( bstate != -1 )    ev_bstate = bstate;
  219.     if( m1 != NULL )    ev_m1 = *m1;
  220.     if( m2 != NULL )    ev_m2 = *m2;
  221.     if( time != -1L )    ev_time = time;
  222. }
  223.  
  224.  
  225.  
  226.  
  227.  
  228.